package com.lnsoft.cac;

import com.lnsoft.cac.server.CACServer;
import com.lnsoft.cac.server.handle.threadpools.ServiceInvokePools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ApplicationClosedListener  implements ApplicationListener<ContextClosedEvent> {

    @Autowired
    private CACServer cacServer;

    @Autowired
    private ServiceInvokePools serviceInvokePools;

    @Override

    public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
        log.info("应用关闭");
        serviceInvokePools.clearPools();
        cacServer.stop();
    }
}
